#include <vector>
#include <iostream>
#include <string>

using namespace std;

//函数模版
template <typename T> inline T const &Max(T const &a, T const &b) {
    return a>b ?a: b;
}


//类模版
template <class T0, class T1> class Stack {
    private:
        vector<T0> elems;
    public:
        void push(T0 const &e);
        T0 pop(void);
        T0 top(void) const;
        bool empty(void) const {
            return elems.empty();
        }
    
};

//类函数定义模版
template <class T0, class T1> void Stack<T0, T1>::push(T0 const &e) {
    elems.push_back(e);
}

template <class T0, class T1> T0 Stack<T0, T1>::pop(void) {
    T0 t = top();
    elems.pop_back();
    return t;
}

template <class T0, class T1> T0 Stack<T0, T1>::top(void) const {
    if(elems.empty()) {
        cout << "Stack<T0, T1>::top(): empty stack!" << endl;
    }
    return elems.back();
}

Stack <int, string>;

int main(void)
{
    
    Stack <int, string> iobj;   
    Stack <string, int> sobj; 
    cout << "Max(1, 2): " << Max(1, 2) << endl;    
    cout << "Max(1.01, 2.1): " << Max(1.01, 2.1) << endl;    
    iobj.push(1);
    cout << "Stack<int, string>::pop(): " << iobj.pop() << endl;
    sobj.push("Hi");
    cout << "Stack<string, int>::pop(): " << sobj.pop() << endl;
    return 0;
}
